home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / dev / gcc / gcc270cp.lha / gnu / lib / g++-include / pair.h < prev    next >
C/C++ Source or Header  |  1995-07-28  |  1KB  |  44 lines

  1. /*
  2.  *
  3.  * Copyright (c) 1994
  4.  * Hewlett-Packard Company
  5.  *
  6.  * Permission to use, copy, modify, distribute and sell this software
  7.  * and its documentation for any purpose is hereby granted without fee,
  8.  * provided that the above copyright notice appear in all copies and
  9.  * that both that copyright notice and this permission notice appear
  10.  * in supporting documentation.  Hewlett-Packard Company makes no
  11.  * representations about the suitability of this software for any
  12.  * purpose.  It is provided "as is" without express or implied warranty.
  13.  *
  14.  */
  15.  
  16. #ifndef PAIR_H
  17. #define PAIR_H
  18.  
  19. #include <bool.h>
  20.  
  21. template <class T1, class T2>
  22. struct pair {
  23.     T1 first;
  24.     T2 second;
  25.     pair(const T1& a, const T2& b) : first(a), second(b) {}
  26. };
  27.  
  28. template <class T1, class T2>
  29. inline bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y) { 
  30.     return x.first == y.first && x.second == y.second; 
  31. }
  32.  
  33. template <class T1, class T2>
  34. inline bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y) { 
  35.     return x.first < y.first || (!(y.first < x.first) && x.second < y.second); 
  36. }
  37.  
  38. template <class T1, class T2>
  39. inline pair<T1, T2> make_pair(const T1& x, const T2& y) {
  40.     return pair<T1, T2>(x, y);
  41. }
  42.  
  43. #endif
  44.